# chatui.py

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(900, 750)
        
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(Form)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setSpacing(0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        
        # --- 左侧联系人面板 ---
        self.contact_list_panel = QtWidgets.QWidget(Form)
        self.contact_list_panel.setObjectName("ContactListPanel")
        self.contact_list_panel.setMinimumSize(QtCore.QSize(260, 0))
        self.contact_list_panel.setMaximumSize(QtCore.QSize(260, 16777215))
        
        self.contact_panel_layout = QtWidgets.QVBoxLayout(self.contact_list_panel)
        self.contact_panel_layout.setContentsMargins(10, 10, 10, 10)
        self.contact_panel_layout.setSpacing(10)
        
        # --- 【修改点1】: 重构搜索栏布局 ---
        # 1. 创建一个容器Widget，用于实现圆角背景
        self.search_bar_widget = QtWidgets.QWidget(self.contact_list_panel)
        self.search_bar_widget.setObjectName("SearchBarContainer")
        
        # 2. 创建水平布局，用于精确放置图标和输入框
        self.search_layout = QtWidgets.QHBoxLayout(self.search_bar_widget)
        self.search_layout.setContentsMargins(10, 0, 5, 0) # 左边距10，其他为0
        self.search_layout.setSpacing(5)
        
        # 3. 创建用于显示搜索图标的Label
        self.search_icon_label = QtWidgets.QLabel(self.search_bar_widget)
        self.search_icon_label.setObjectName("SearchIconLabel")
        self.search_icon_label.setMinimumSize(QtCore.QSize(20, 20))
        self.search_icon_label.setMaximumSize(QtCore.QSize(20, 20))
        # 提示: 您需要在逻辑代码中为 self.search_icon_label 设置图标
        # 例如: self.search_icon_label.setPixmap(QtGui.QPixmap(":/icons/search.png").scaled(16, 16, QtCore.Qt.KeepAspectRatio))
        self.search_icon_label.setText("") # 确保没有文本
        self.search_layout.addWidget(self.search_icon_label)
        
        # 4. 将原有的QLineEdit放入新布局中
        self.lineEdit = QtWidgets.QLineEdit(self.search_bar_widget)
        self.lineEdit.setObjectName("SearchBox")
        self.search_layout.addWidget(self.lineEdit)
        
        # 5. 将整个搜索栏容器添加到主布局
        self.contact_panel_layout.addWidget(self.search_bar_widget)
        # --- 搜索栏重构结束 ---
        
        # 联系人列表
        self.listWidget = QtWidgets.QListWidget(self.contact_list_panel)
        self.listWidget.setObjectName("ContactList")
        self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.contact_panel_layout.addWidget(self.listWidget)
        
        self.horizontalLayout_2.addWidget(self.contact_list_panel)
        
        # --- 右侧聊天内容区 ---
        self.stackedWidget = QtWidgets.QStackedWidget(Form)
        self.stackedWidget.setObjectName("stackedWidget")
        self.horizontalLayout_2.addWidget(self.stackedWidget)
        self.horizontalLayout_2.setStretch(1, 1)

        self.retranslateUi(Form)
        self.stackedWidget.setCurrentIndex(-1)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Chat"))
        self.lineEdit.setPlaceholderText(_translate("Form", "搜索"))